package com.myway.controller;

//import com.myway.front.service.ITestService;
import com.alibaba.fastjson.JSON;
import com.myway.dto.common.JsonData;
import com.myway.service.TicketService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2018/8/12.
 */
@Controller
@Slf4j
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private TicketService ticketService;

   @RequestMapping("/kkOrder")
   @ResponseBody
   public String kkOrder(HttpServletRequest request, @RequestParam("orderNo") String orderNo)throws Exception{
       request.setCharacterEncoding("utf-8");
       JsonData json=ticketService.handleTicket(orderNo);
       log.info(JSON.toJSONString(json));
       return JSON.toJSONString(json);
   }

    @RequestMapping("/reIssue")
    @ResponseBody
    public String reIssue(HttpServletRequest request, @RequestParam("orderNo") String orderNo){
        try {
            request.setCharacterEncoding("utf-8");
            JsonData json=ticketService.reIssue(orderNo);
            return JSON.toJSONString(json);
        }catch (Exception e){
               e.printStackTrace();
               return JSON.toJSONString(JsonData.fail("出现异常"));
        }
    }


}
